package core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Review {
    private String id;
    private HashMap<Integer, Double> content;
    private List<Integer> note;
    private String user;
    private String beer;
    
    public Review (String id, String beer, String user, HashMap<Integer,Double> content, List<Integer> note){
        this.setId(id);
        this.setBeer(beer);	
        this.setUser(user);
        this.content = content;
        this.note = note;        
    }
    
    public HashMap<Integer, Double> getContent() {
        return content;
    }
    
    public List<Integer> getNote() {
        return note;
    }
    
    public int getNote(int noteID) {
        return note.get(noteID);
    }
    
    public boolean isSameReviewButDifNote(Review r, int noteID) {
    	if (note.get(noteID) == r.getNote(noteID)) {
    		return false;
    	} else {
    		/*if (content.size() != r.getContent().size()) {
    			return false;
    		} else {
    			int i = 0;
    			while (i < content.size()) {
    				if (!content.keySet().toArray()[i].equals(r.getContent().keySet().toArray()[i]) 
    						|| !content.get(content.keySet().toArray()[i]).equals(r.getContent().get(r.getContent().keySet().toArray()[i]))) {
    					return false;
	    			}
    				i++;
    			}

    			
    			return true;
    		}   */
    		return content.keySet().equals(r.getContent().keySet());
    	}
    }

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getBeer() {
		return beer;
	}

	public void setBeer(String beer) {
		this.beer = beer;
	}
	
	public List<Integer> getFreqArray() {
		List<Integer> freq = new ArrayList<Integer>();
		for (int key : getContent().keySet()) {
			if (key != 50239) {
				freq.add(key);
			}
		}
		
		return freq;
	}
}
